local fk__fapi = fk.CreateSkill {

  name = "fk__fapi",

  tags = {  },

}

local U = require "packages/utility/utility"


fk__fapi:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(fk__fapi.name) and player ~= target and target.phase == Player.Finish and player.hp > 0
  end,
  on_cost = function(self, event, target, player, data)
    return player.room:askForSkillInvoke(player, fk__fapi.name, nil, "#fk__fapi-invoke::"..target.id)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:loseHp(player, 1, fk__fapi.name)
    if not player.dead then
      player:drawCards(1, fk__fapi.name)
    end
    local card = Fk:cloneCard("slash")
    card.skillName = fk__fapi.name
    local use = {card = card, from = player, tos = {target}, extraUse = true}
    if not player:isProhibited(target, card) and not player:prohibitUse(card) then
      room:useCard(use)
    end
    if use.damageDealt and not player.dead then
      player:drawCards(1, fk__fapi.name)
    end
  end,
})

return fk__fapi